#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    init_slots();

    ui->red_hs->setRange(0, 255);
    ui->green_hs->setRange(0, 255);
    ui->blue_hs->setRange(0, 255);
    ui->alpha_hs->setRange(0, 255);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::init_slots()
{
    QObject::connect(ui->red_hs, SIGNAL(valueChanged(int)), SLOT(on_hs_valueChanged(int)));
    QObject::connect(ui->green_hs, SIGNAL(valueChanged(int)), SLOT(on_hs_valueChanged(int)));
    QObject::connect(ui->blue_hs, SIGNAL(valueChanged(int)), SLOT(on_hs_valueChanged(int)));
    QObject::connect(ui->alpha_hs, SIGNAL(valueChanged(int)), SLOT(on_hs_valueChanged(int)));
}


void Widget::on_hs_valueChanged(int value)
{
    qDebug("hs moved");
    QColor color;
    color.setRgb(ui->red_hs->value(), ui->green_hs->value(), ui->blue_hs->value(), ui->alpha_hs->value());

    QPalette pla = ui->color_te->palette();
    pla.setColor(QPalette::Base,color);

    ui->color_te->setPalette(pla);
}

void Widget::on_dial_valueChanged(int value)
{
    ui->lcdNumber->display(value);
}
